package com.ledim.adapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.ledim.ledimview.ViewPagerSearchListView;
import java.util.List;

public class SearchPagerAdapter extends PagerAdapter {

    public List<ViewPagerSearchListView> list;
    private LayoutInflater mInflater;
    private Context mContext;

    public SearchPagerAdapter(Context context, List<ViewPagerSearchListView> list) {
        mInflater = LayoutInflater.from(context);
        this.mContext = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(list.get(position));
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(list.get(position), 0);//添加页卡
        return list.get(position);
    }

    @Override
    public boolean isViewFromObject(View arg0, Object arg1) {
        return arg0 == arg1;//官方提示这样写
    }

}
